<?php
require 'functions.php';
require_once '../data/data.php';
header("Content-type:text/html;charset=utf-8");

$Number = input('Number');
$Name = input('Name');
$IDcard = input('IDcard',18);
$Gender = input('Gender',1);
$Birth = input('Birth','1995-01-01');
$Grade = input('Grade',1);
$University = input('University','华侨大学');
$School = input('School','信息学院');
$Major = input('Major','电子信息工程');
$GPA = input('GPA',3.00);
$description = input('describ');

if (empty($Number)) {
	error('学号不能为空','../stu_info.php?op=1');
	return;
}

if (empty($Name)) {
	error('请输入姓名','../stu_info.php?op=1');
	return;
}

if (empty($IDcard)) {
	error('请输入身份证','../stu_info.php?op=1');
	return;
}

$sql = 'insert into students(Number,Name,IDcard,Gender,Birth,Grade,University,School,Major,GPA,Introduction) values(?,?,?,?,?,?,?,?,?,?,?)';
$args = [$Number,$Name,$IDcard,$Gender,$Birth,$Grade,$University,$School,$Major,$GPA,$description];

$affected = execute($sql,$args);
//根据影响的行数判断sql语句是否执行成功
if ($affected == 1) {
	error('新增用户信息成功','../index.php');
}else{
	error('新增用户信息失败','../stu_info.php?op=1');
	return;
}

?>

<style type="text/css">
	li{
		list-style: none;
	}
</style>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>message</title>
</head>
<body>
  <ul>
  	<li>学号：<?=$Number ?></li>
  	<li>姓名：<?=$Name ?></li>
  	<li>身份证：<?=$IDcard ?></li>
  	<li>性别：<?=$Gender == 1?'男':'女' ?></li>
  	<li>生日：<?=$Birth ?></li>
    <li>年级：<?=$Grade ?></li>
    <li>大学：<?=$University ?></li>
    <li>学院：<?=$School ?></li>
    <li>专业：<?=$Major ?></li>
    <li>绩点：<?=$GPA ?></li>
    <li>自我介绍：<?=$description ?></li>
  </ul>
</body>
</html>